﻿
/*----------------------------------------------------------------
 * 创建时间：2023/8/21 13:43:38
 * 作  者：wenlli 
 * 项  目：Minotaur.App.Domains.ViewModel.Resources 
 * 描  述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时  间：
 * 修改说明：
 * 
 *----------------------------------------------------------------*/


using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Minotaur.App.Domains.ViewModel.Resources
{
    public class ResourcesViewModel : BindableBase
    {

        private bool isChecked;

        /// <summary>
        /// 主键ID
        /// </summary>
        public virtual long Autoid { get; set; }
        /// <summary>
        /// 菜单编码
        /// </summary>
        public virtual string? MenuCode { get; set; }

        private string? _Resoucestype;
        /// <summary>
        /// 资源类型
        /// </summary>
        public virtual string? Resoucestype
        {
            get => _Resoucestype;
            set
            {
                SetProperty(ref _Resoucestype, value);
                if (!string.IsNullOrEmpty(value))
                {
                    Dictionary<string, string> map = new Dictionary<string, string>();
                    map["info"] = "信息";
                    map["error"] = "错误";
                    map["warning"] = "警告";
                    DisResoucestype = map[value];
                    Dictionary<string, string> Colors = new Dictionary<string, string>();
                    Colors["info"] = "#409EFF";
                    Colors["error"] = "#F56C6C";
                    Colors["warning"] = "#E6A23C";
                    DisResoucesTypeColor = Colors[value];
                }
            }
        }
        public virtual string? DisResoucestype { get; set; }

        /// <summary>
        /// 资源类型背景
        /// </summary>
        public virtual string? DisResoucesTypeColor { get; set; }
        /// <summary>
        /// 资源编码
        /// </summary>
        public virtual string? ResCode { get; set; }

        /// <summary>
        /// 资源名称
        /// </summary>
        public virtual string? ResName { get; set; }

        private bool? _Enable;
        /// <summary>
        /// 是否禁用
        /// </summary> 
        public bool? IsEnable
        {
            get => _Enable;
            set
            {
                SetProperty(ref _Enable, value);
                if (value.HasValue && value.Value)
                {
                    RowColor = "#108ee9";
                    DisEnable = "启用";
                    ForeRowColor = "Snow";
                }
                else
                {
                    RowColor = "#f56c6c";
                    DisEnable = "禁用";
                    ForeRowColor = "#f56c6c";
                }
            }
        }
        private string _DisEnable;


        /// <summary>
        /// 启用/禁用
        /// </summary>
        [Newtonsoft.Json.JsonIgnore()]
        public ICommand EnableOrDisabledCommand => new DelegateCommand<object>(EnableOrDisabledAction);

        /// <summary>
        /// 启用/禁用
        /// </summary>
        [Newtonsoft.Json.JsonIgnore()]
        public Action<object> EnableOrDisabledAction { get; set; }


        /// <summary>
        /// 编辑按钮
        /// </summary>
        [Newtonsoft.Json.JsonIgnore()]
        public Action<object> EditAction { get; set; }

        /// <summary>
        /// 编辑按钮
        /// </summary>
        [Newtonsoft.Json.JsonIgnore()]
        public ICommand EditCommand => new DelegateCommand<object>(EditAction);

        /// <summary>
        /// 行颜色
        /// </summary>
        private string rowColor;

        /// <summary>
        /// 行颜色
        /// </summary>
        private string foreRowColor;

        public string CreatDate { get; set; }
        public virtual string CreatorName { get; set; }
        public virtual string Creator { get; set; }

        /// <summary>
        /// 删除命令
        /// </summary>
        [Newtonsoft.Json.JsonIgnore()]
        public ICommand DeleteCommand => new DelegateCommand<object>(DeleteAction);
        [Newtonsoft.Json.JsonIgnore()]
        public Action<object> DeleteAction { get; set; }
        public string DisEnable { get => _DisEnable; set => SetProperty(ref _DisEnable, value); }
        public string RowColor { get => rowColor; set => SetProperty(ref rowColor, value); }
        public string ForeRowColor { get => foreRowColor; set => SetProperty(ref foreRowColor, value); }
        public bool IsChecked { get => isChecked; set => SetProperty(ref isChecked, value); }
        [Newtonsoft.Json.JsonIgnore()]
        public ICommand DetaileCommand => new DelegateCommand<object>(DetaileAction);
        [Newtonsoft.Json.JsonIgnore()]
        public Action<object> DetaileAction { get;   set; }
    }
}
